﻿<UserControl x:Class="MouseExtender.Controls.UserControls.EditItemUC"
						 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
						 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
						 xmlns:c="clr-namespace:System;assembly=mscorlib"
						 xmlns:uc="clr-namespace:MouseExtender.Controls.UserControls"
						 xmlns:common="clr-namespace:MouseExtender.Logic.Common"
						 xmlns:resx="clr-namespace:MouseExtender.Resources"
						 Loaded="UserControl_Loaded">
	<UserControl.Resources>
		<!--Linkbuttons-->
		<Style x:Key="LinkButtonStyle" TargetType="{x:Type Button}">
			<Setter Property="Cursor" Value="Hand"/>
			<Setter Property="Margin" Value="3"/>
			<Setter Property="Focusable" Value="false"/>
			<Setter Property="Height" Value="22"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="Button">
						<TextBlock TextDecorations="Underline">
							<ContentPresenter/>
						</TextBlock>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
			<Setter Property="Foreground" Value="{StaticResource grayBrush}"/>
			<Style.Triggers>
				<Trigger Property="IsMouseOver" Value="true">
					<Setter Property="Foreground" Value="{StaticResource lightGrayBrush}"/>
				</Trigger>
			</Style.Triggers>
		</Style>
		<!--Listbox-->
		<Style x:Key="lbIconsItemStyle" TargetType="{x:Type ListBoxItem}">
			<Style.Resources>
				<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#55888888"/>
			</Style.Resources>
			<EventSetter Event="MouseDoubleClick" Handler="lbIconsItem_DoubleClick"/>
		</Style>
		<Style TargetType="ListBox">
			<Style.Resources>
				<c:Double x:Key="{x:Static SystemParameters.HorizontalScrollBarHeightKey}">14</c:Double>
			</Style.Resources>
		</Style>
		<ItemsPanelTemplate x:Key="lbIconsItemPanelTemplate">
			<StackPanel Orientation="Horizontal" Height="42"/>
		</ItemsPanelTemplate>
		<!--Textblock-->
		<Style TargetType="{x:Type TextBlock}">
			<Setter Property="Foreground" Value="#FF333333"/>
			<Setter Property="Margin" Value="0,3,0,0"/>
		</Style>
		<!--Expander-->
		<Style x:Key="ExpanderHeaderFocusVisual">
			<Setter Property="Control.Template">
				<Setter.Value>
					<ControlTemplate>
						<Border/>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<LinearGradientBrush x:Key="ButtonNormalBackgroundFill" EndPoint="0.5,1" StartPoint="0.5,0">
			<GradientStop Color="White" Offset="0"/>
			<GradientStop Color="#FFE3E5F0" Offset="0.5"/>
			<GradientStop Color="#FFC6C5D7" Offset="1.0"/>
		</LinearGradientBrush>
		<LinearGradientBrush x:Key="ExpanderShadowFill" EndPoint="0,1" StartPoint="0,0">
			<GradientStop Color="Transparent" Offset="0.5"/>
			<GradientStop Color="#30111111" Offset="1"/>
		</LinearGradientBrush>
		<Style x:Key="ExpanderDownHeaderStyle" TargetType="{x:Type ToggleButton}">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type ToggleButton}">
						<Border Padding="{TemplateBinding Padding}">
							<Grid SnapsToDevicePixels="False" Background="Transparent">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="19"/>
									<ColumnDefinition Width="*"/>
								</Grid.ColumnDefinitions>
								<Ellipse HorizontalAlignment="Center" x:Name="circle" VerticalAlignment="Center" Width="19" Height="19" Fill="{DynamicResource ButtonNormalBackgroundFill}" Stroke="DarkGray"/>
								<Ellipse Visibility="Hidden" HorizontalAlignment="Center" x:Name="shadow" VerticalAlignment="Center" Width="17" Height="17" Fill="{DynamicResource ExpanderShadowFill}"/>
								<Path SnapsToDevicePixels="false" HorizontalAlignment="Center" x:Name="arrow" VerticalAlignment="Center" Stroke="#666" StrokeThickness="2" Data="M1,1.5 L4.5,5 L8,1.5"/>
								<ContentPresenter SnapsToDevicePixels="True" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Center" Grid.Column="1" RecognizesAccessKey="True"/>
							</Grid>
						</Border>
						<ControlTemplate.Triggers>
							<Trigger Property="IsChecked" Value="true">
								<Setter Property="Data" TargetName="arrow" Value="M1,4.5 L4.5,1 L8,4.5"/>
							</Trigger>
							<Trigger Property="IsMouseOver" Value="true">
								<Setter Property="Stroke" TargetName="circle" Value="#666"/>
								<Setter Property="Stroke" TargetName="arrow" Value="#222"/>
								<Setter Property="Visibility" TargetName="shadow" Value="Visible"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<Style x:Key="ExpanderUpHeaderStyle" TargetType="{x:Type ToggleButton}">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type ToggleButton}">
						<Border Padding="{TemplateBinding Padding}">
							<Grid SnapsToDevicePixels="False" Background="Transparent">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="19"/>
									<ColumnDefinition Width="*"/>
								</Grid.ColumnDefinitions>
								<Grid>
									<Grid.LayoutTransform>
										<TransformGroup>
											<TransformGroup.Children>
												<TransformCollection>
													<RotateTransform Angle="180"/>
												</TransformCollection>
											</TransformGroup.Children>
										</TransformGroup>
									</Grid.LayoutTransform>
									<Ellipse HorizontalAlignment="Center" x:Name="circle" VerticalAlignment="Center" Width="19" Height="19" Fill="{DynamicResource ButtonNormalBackgroundFill}" Stroke="DarkGray"/>
									<Ellipse Visibility="Hidden" HorizontalAlignment="Center" x:Name="shadow" VerticalAlignment="Center" Width="17" Height="17" Fill="{DynamicResource ExpanderShadowFill}"/>
									<Path SnapsToDevicePixels="false" HorizontalAlignment="Center" x:Name="arrow" VerticalAlignment="Center" Stroke="#666" StrokeThickness="2" Data="M1,1.5 L4.5,5 L8,1.5"/>
								</Grid>
								<ContentPresenter SnapsToDevicePixels="True" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Center" Grid.Column="1" RecognizesAccessKey="True"/>
							</Grid>
						</Border>
						<ControlTemplate.Triggers>
							<Trigger Property="IsChecked" Value="true">
								<Setter Property="Data" TargetName="arrow" Value="M1,4.5 L4.5,1 L8,4.5"/>
							</Trigger>
							<Trigger Property="IsMouseOver" Value="true">
								<Setter Property="Stroke" TargetName="circle" Value="#666"/>
								<Setter Property="Stroke" TargetName="arrow" Value="#222"/>
								<Setter Property="Visibility" TargetName="shadow" Value="Visible"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<Style x:Key="expanderStyle" TargetType="{x:Type Expander}">
			<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
			<Setter Property="Background" Value="Transparent"/>
			<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
			<Setter Property="VerticalContentAlignment" Value="Stretch"/>
			<Setter Property="BorderBrush" Value="Transparent"/>
			<Setter Property="BorderThickness" Value="1"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type Expander}">
						<ControlTemplate.Resources>
							<Storyboard x:Key="Timeline1">
								<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:0.25" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
									<SplineDoubleKeyFrame KeyTime="00:00:0.25" Value="1"/>
								</DoubleAnimationUsingKeyFrames>
							</Storyboard>
							<Storyboard x:Key="Timeline2">
								<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.45" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
									<SplineDoubleKeyFrame KeyTime="00:00:0.45" Value="0"/>
								</DoubleAnimationUsingKeyFrames>
							</Storyboard>
						</ControlTemplate.Resources>
						<Border SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3">
							<DockPanel>
								<ToggleButton FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" FocusVisualStyle="{StaticResource ExpanderHeaderFocusVisual}" Margin="1" MinHeight="0" MinWidth="0" x:Name="HeaderSite" Style="{StaticResource ExpanderDownHeaderStyle}" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" DockPanel.Dock="Top"/>
								<ContentPresenter Focusable="false" Visibility="Visible" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" x:Name="ExpandSite" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" DockPanel.Dock="Bottom">
									<ContentPresenter.LayoutTransform>
										<TransformGroup>
											<ScaleTransform ScaleX="1" ScaleY="0"/>
										</TransformGroup>
									</ContentPresenter.LayoutTransform>
								</ContentPresenter>
							</DockPanel>
						</Border>
						<ControlTemplate.Triggers>
							<Trigger Property="IsExpanded" Value="True">
								<Trigger.EnterActions>
									<BeginStoryboard Storyboard="{StaticResource Timeline1}"/>
								</Trigger.EnterActions>
								<Trigger.ExitActions>
									<BeginStoryboard Storyboard="{StaticResource Timeline2}"/>
								</Trigger.ExitActions>
							</Trigger>
							<Trigger Property="ExpandDirection" Value="Up">
								<Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Top"/>
								<Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Bottom"/>
								<Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderUpHeaderStyle}"/>
							</Trigger>
							<Trigger Property="IsEnabled" Value="false">
								<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</UserControl.Resources>
	<Grid Width="296">
		<Grid.RowDefinitions>
			<RowDefinition Height="*"/>
			<RowDefinition Height="Auto" MinHeight="39"/>
		</Grid.RowDefinitions>
		<StackPanel Width="276" Margin="10" Grid.Row="0" Orientation="Vertical" SnapsToDevicePixels="True">
			<TextBlock x:Name="lblFileUrl" Height="20"/>
			<TextBox x:Name="txtFile" MaxLength="200" Text="{Binding LaunchPath}" Height="22"/>
			<TextBlock Height="20" Text="{x:Static resx:UIResources.EditItem_Tooltip}"/>
			<TextBox x:Name="txtToolTip" MaxLength="200" Height="22" Text="{Binding ToolTip}"/>
			<TextBlock x:Name="lblArguments" Height="20" Text="{x:Static resx:UIResources.EditItem_Arguments}"/>
			<TextBox x:Name="txtArguments" MaxLength="200" Text="{Binding Arguments}" Height="22"/>
			<TextBlock x:Name="lblDirectory" Height="20" Text="{x:Static resx:UIResources.EditItem_WorkingDirectory}"/>
			<TextBox x:Name="txtDirectory" MaxLength="200" Text="{Binding WorkingDirectory}" Height="22"/>
			<StackPanel>
				<!--Animation for expander-->
				<StackPanel.Triggers>
					<EventTrigger RoutedEvent="Expander.Expanded" SourceName="expander">
						<EventTrigger.Actions>
							<BeginStoryboard>
								<Storyboard>
									<DoubleAnimation From="0" To="1" Duration="0:0:0.25" Storyboard.TargetName="spIconSource" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(ScaleTransform.ScaleY)"/>
								</Storyboard>
							</BeginStoryboard>
						</EventTrigger.Actions>
					</EventTrigger>
					<EventTrigger RoutedEvent="Expander.Collapsed" SourceName="expander">
						<EventTrigger.Actions>
							<BeginStoryboard>
								<Storyboard>
									<DoubleAnimation From="1" To="0" Duration="0:0:0.25" Storyboard.TargetName="spIconSource" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(ScaleTransform.ScaleY)"/>
								</Storyboard>
							</BeginStoryboard>
						</EventTrigger.Actions>
					</EventTrigger>
				</StackPanel.Triggers>
				<Expander x:Name="expander" Style="{StaticResource expanderStyle}">
					<Expander.HeaderTemplate>
						<DataTemplate>
							<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
								<Image x:Name="imgIcon" Margin="5" Width="32" Height="32" Source="{Binding}"/>
								<TextBlock VerticalAlignment="Center" Foreground="#FF333333" Text="{x:Static resx:UIResources.EditItem_ChangeIcon}"/>
							</StackPanel>
						</DataTemplate>
					</Expander.HeaderTemplate>
					<StackPanel x:Name="spIconSource">
						<TextBox x:Name="txtFileName" Height="22" Text="{Binding IconSource}" IsReadOnly="True"/>
						<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
							<Button Content="{x:Static resx:UIResources.Buttons_Browse}" Style="{StaticResource LinkButtonStyle}" Click="btnBrowse_Click"/>
							<Button Content="{x:Static resx:UIResources.EditItem_ResetIcon}" Style="{StaticResource LinkButtonStyle}" Click="btnReset_Click"/>
						</StackPanel>
						<ListBox x:Name="lbAvailableIcons" ItemsPanel="{StaticResource lbIconsItemPanelTemplate}" BorderBrush="{x:Null}" ItemContainerStyle="{StaticResource lbIconsItemStyle}"/>
						<StackPanel.LayoutTransform>
							<ScaleTransform ScaleX="1" ScaleY="1"/>
						</StackPanel.LayoutTransform>
					</StackPanel>
				</Expander>
			</StackPanel>
		</StackPanel>
		<StackPanel HorizontalAlignment="Right" Grid.Row="1" Orientation="Horizontal" Margin="5,5,10,10">
			<Button Command="common:Commands.SaveItemSettings" Style="{StaticResource SettingsButtons}" IsDefault="True" Click="AnyButton_Click" Content="{x:Static resx:UIResources.Buttons_OK}"/>
			<Button Command="common:Commands.CancelPopup" Style="{StaticResource SettingsButtons}" IsCancel="True" Click="AnyButton_Click" Content="{x:Static resx:UIResources.Buttons_Cancel}"/>
		</StackPanel>
	</Grid>
</UserControl>
